import 'package:fluro/fluro.dart';
import 'package:fluro/src/router.dart';
import 'package:flutter/material.dart';
import 'package:study_flutter/router/IRouterProvider.dart';
import 'package:study_flutter/yzhg/function/yrouter/YFluroParameter.dart';
import 'package:study_flutter/yzhg/function/yrouter/YNoFluroParameter.dart';
import 'package:study_flutter/yzhg/project/shop/pages/goodsdetail/YGoodsDetailPages.dart';

class RoutesPath extends IRouterProvider {
  static String parameterPath = "/yzhg/function/yrouter/YFluroParameter";
  static String noParameterPath = "/yzhg/function/yrouter/YNoFluroParameter";

  /*配置商品详情页面*/
  static String goodsDetail = "/yzhg/project/shop/pages/goodsdetail/YGoodsDetailPages";

  @override
  void initRouter(Router router) {
    var parameterHandler = new Handler(handlerFunc:
        (BuildContext context, Map<String, List<String>> parameters) {
      return new YFluroParameter();
    });

    var noParameterHandler = new Handler(handlerFunc:
        (BuildContext context, Map<String, List<String>> parameters) {
      String url = parameters["param1"].first;
      String title = parameters["param2"].first;
      return new YNoFluroParameter(url, title);
    });

    /*商品详情页面数据配置*/
    var shopDetailHandler = new Handler(handlerFunc:
        (BuildContext context, Map<String, List<String>> parameters) {
      String goodsId = parameters["goodsId"].first;
      return new YGoodsDetailPages(goodsId: goodsId);
    });

    router.define(parameterPath, handler: parameterHandler);
    router.define(noParameterPath, handler: noParameterHandler);

    /*跳转到商品详情*/
    router.define(goodsDetail, handler: shopDetailHandler);
  }
}
